/*
* IQR.cs
* 
* Copyright (c) 2006, dnAnalytics. All rights reserved.
*/

#region Using Directives

using System;
using dnAnalytics.Exceptions;
using dnAnalytics.Math;

#endregion

namespace dnAnalytics.LinearAlgebra.Decomposition
{
    /// <summary>
    /// Interface for computing the QR decomposition of a
    /// <see cref="Matrix"/>.
    /// </summary>
    internal interface IQR : IAlgorithm
    {
        /// <summary>
        /// Determines whether the matrix is full rank or not.
        /// </summary>
        /// <returns><b>true</b> if the matrix is full rank; otherwise <b>false</b>.</returns>        
        bool IsFullRank();

        /// <summary>
        /// Returns the orthogonal Q matrix.
        /// </summary>
        /// <returns>The orthogonal Q matrix.</returns>
        Matrix Q();

        /// <summary>
        /// Copies the orthogonal Q matrix into the result matrix.
        /// </summary>
        /// <param name="result">A matrix to copy the orthogonal Q matrix into.</param>
        void Q(Matrix result);

        /// <summary>
        /// Returns the upper triangular factor R.
        /// </summary>
        /// <returns>The upper triangular factor R.</returns>
        Matrix R();

        /// <summary>
        /// Copies the upper triangular factor R into the result matrix.
        /// </summary>
        /// <param name="result">A matrix to copy upper triangular factor R into.</param>
        void R(Matrix result);

        ///<summary>Calculates the determinant (absolute value) of the matrix.</summary>
        ///<returns>The determinant of the matrix.</returns>
        double Determinant();

        /// <summary>
        /// Finds the least squares solution of <b>A*X = B</b>, where <b>m &lt;= n</b>
        /// </summary>
        /// <param name="rightHandSide">The right hand side <see cref="Matrix"/>, <b>B</b>.</param>
        /// <returns>The left hand side <see cref="Matrix"/>, <b>X</b>.</returns>
        Matrix Solve(Matrix rightHandSide);

        /// <summary>
        /// Finds the least squares solution of <b>A*X = B</b>, where <b>m &lt;= n</b>
        /// </summary>
        /// <param name="rightHandSide">The right hand side <see cref="Matrix"/>, <b>B</b>.</param>
        /// <param name="result">The left hand side <see cref="Matrix"/>, <b>X</b>.</param>
        void Solve(Matrix rightHandSide, Matrix result);

        /// <summary>
        /// Finds the least squares solution of <b>A*x = b</b>, where <b>m &lt;= n</b>
        /// </summary>
        /// <param name="rightHandSide">The right hand side vector, <b>b</b>.</param>
        /// <returns>The left hand side <see cref="Vector"/>, <b>x</b>.</returns>
        Vector Solve(Vector rightHandSide);

        /// <summary>
        /// Finds the least squares solution of <b>A*x = b</b>, where <b>m &lt;= n</b>
        /// </summary>
        /// <param name="rightHandSide">The right hand side <see cref="Vector"/>, <b>b</b>.</param>
        /// <param name="result">The left hand side <see cref="Vector"/>, <b>x</b>.</param>
        void Solve(Vector rightHandSide, Vector result);
    }
}
